package com.lavida.project.wage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lavida.project.wage.domain.NewWageAccount;
import com.lavida.project.wage.domain.ProvideRecord;
import com.lavida.project.wage.mapper.NewWageAccountMapper;
import com.lavida.project.wage.mapper.ProvideRecordMapper;
import com.lavida.project.wage.service.ProvideRecordService;

@Service
public class ProvideRecordServiceImpl implements ProvideRecordService{
	
	@Autowired
	private ProvideRecordMapper provideRecordMapper;
	
	@Autowired
	private NewWageAccountMapper newWageAccountMapper;


	@Override
	public List<ProvideRecord> selectProvideRecordList(ProvideRecord provideRecord) {
		// TODO Auto-generated method stub
		return provideRecordMapper.selectProvideRecordList(provideRecord);
	}

	@Override
	public Integer addProvideRecord(ProvideRecord provideRecord) {
		// TODO Auto-generated method stub
		return provideRecordMapper.addProvideRecord(provideRecord);
	}

	@Override
	public Integer deleteProvideRecord(ProvideRecord provideRecord) {
		// TODO Auto-generated method stub
		return provideRecordMapper.deleteProvideRecord(provideRecord);
	}

	@Override
	public ProvideRecord getLastProvideRecord(ProvideRecord provideRecord) {
		// TODO Auto-generated method stub
		return provideRecordMapper.getLastProvideRecord(provideRecord);
	}

	@Override
	@Transactional
	public Integer editProvideRecord(ProvideRecord provideRecord) {
		// TODO Auto-generated method stub
		//更新创建者、创建时间
		int rows = provideRecordMapper.editProvideRecord(provideRecord);
		//删除指定年月的核算新工资
		NewWageAccount newWageAccount = new NewWageAccount();
		newWageAccount.setYear(provideRecord.getYear());
		newWageAccount.setMonth(provideRecord.getMonth());
		newWageAccountMapper.deleteNewWageAccount(newWageAccount);
		return rows;
	}

	@Override
	public ProvideRecord getProvideRecord(ProvideRecord provideRecord) {
		// TODO Auto-generated method stub
		return provideRecordMapper.getProvideRecord(provideRecord);
	}
	

}
